home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_54516.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  22 lines

  1. -- card: 54516 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. TC/C++ CONSIDERATIONS
  11.  
  12. When taking advantage of the ability to define classes in TC and C++, it is common practice to place each class definition in a header file, and the definitions of the member functions of the class in a separate source file.  In the example in Chapter 4 the Person class was defined in 'person.h' and its methods in 'person.c'.  The source file #includes the corresponding header, as do all files which make use of the Person class definition; namely 'student.h' and 'main.c'.
  13.  
  14. Notice that 'main.c' #includes 'student.h' as well.  This suggests that the contents of       'person.h' are included twice in 'main.c', producing an error due to duplicate definition.  To avoid this, Think C allows the programmer to place the directive:
  15.  
  16.     # define    _H_person.h
  17.  
  18. at the beginning of the header 'person.h'.  This ensures the file's contents are compiled only once.  In C++ conditional compilation must be made explicitly, as discussed in the following section.
  19.  
  20. -- part contents for background part 7
  21. ----- text -----
  22. 177